﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<OurSite.WebAdmin.Models.ListingImageEdit>" %>
<%@ Import Namespace="OurSite.Business.Picture"%>
<%@ Import Namespace="OurSite.Business.Event"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Manage Events
</asp:Content>

<asp:Content id="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
<script>
    function SetListingImage(type, pictureId, categoryId, name)
    {
        $.ajax({
            url: "/Event.aspx/SetCategoryListingImage",
            data: ({ type: type, pictureId: pictureId, categoryId: categoryId, name: name }),
            success: function(data)
            {
                $("#currentLisingImage").html('<img src="\<%=ConfigurationManager.AppSettings["ImagePrefix"] %>' + 'Small' + data + '\">');
            }
        });
    }
</script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%= Model.Name %></h2>
    <div id="currentLisingImage">
        <%= Model.CurrentLisingImage != null ? "<img src='" + ConfigurationManager.AppSettings["ImagePrefix"] + "Small" + Model.CurrentLisingImage.ImagePath + "'/>" : "No image set"%>
    </div>
    <div>
        <%foreach (Picture p in Model.PossibleLisingImage){ %>
            <div class="listingImage">
                <img onclick="SetListingImage('<%=Model.Type %>', '<%=p.Id %>', '<%=Model.Id %>', '<%=Model.Name %>');" src="<%= ConfigurationManager.AppSettings["ImagePrefix"] + "Small" + p.ImagePath%>" class="thumbnailLarger"/>
            </div>
        <%} %>
    </div>
    <div class="clearBoth"></div>
</asp:Content>
